package codeGeneration;

import cn.hutool.core.util.StrUtil;
import lombok.Data;

@Data
public class Config {
    private String basePath = "./out/";
    //    private String basePath = "D:\\Work\\WorkSpace\\platform";
    private String type = "customer";
    private String folder = "company";
    private String customerPath = "api-customer/src/main/java/com/oleasy/platform/api/customer/modules";
    private String adminPath = "api-admin/src/main/java/com/oleasy/platform/api/admin/modules";
    private String entityPath = "common-data/src/main/java/com/oleasy/platform/api/common";
    private String customerPackagePre = "com.oleasy.platform.api.customer.modules";
    private String adminPackagePre = "com.oleasy.platform.api.admin.modules";
    private String tableName = "";
    private String entityName = "";
    private String lowEntityName = "";
    private String packageName = "";
    private String name = "";


    public String getEntityName() {
        if (StrUtil.isBlank(entityName)) {
            this.entityName = StrUtil.upperFirst(getLowEntityName());
        }
        return entityName;
    }

    public String getLowEntityName() {
        if (StrUtil.isBlank(lowEntityName)) {
            this.lowEntityName = StrUtil.toCamelCase(getTableName());
        }
        return lowEntityName;
    }

    public String getFilePath() {
        if (this.type.equals("customer")) {
            return String.format("%s/%s/%s", basePath, customerPath, folder);
        } else {
            return String.format("%s/%s/%s", basePath, adminPath, folder);
        }
    }

    public String getBaseFilePath() {
        return String.format("%s/%s", basePath, entityPath);
    }

    public String getPackageName() {
        if (this.type.equals("customer")) {
            return String.format("%s.%s", customerPackagePre, folder);
        } else {
            return String.format("%s.%s", adminPackagePre, folder);
        }
    }
}
